﻿<div class="wrapper">
<script src="http://maps.google.com/maps/api/js?sensor=false&region=BD"></script>
<script>
//var DoctorNamespace= (function(){
var directionsDisplay;

var map;
var geocoder;
var directionsService;
var address = "BUET";

function geocodeGivenAddress(){
	geocoder = new google.maps.Geocoder();
	var latlng = new google.maps.LatLng(0, 0);
    var mapOptions = {
		zoom: 16
//		center: new google.maps.LatLng(23.0,90.0)
    }
	geocoder.geocode( { 'address': address}, function(results, status) {
		if (status == google.maps.GeocoderStatus.OK) {
			mapOptions.center = results[0].geometry.location;

			directionsDisplay.setMap(map);
			directionsDisplay.setPanel(document.getElementById('directions'));
			map.setCenter(results[0].geometry.location);
			var image = 'images/bookmark.png';

			var marker = new google.maps.Marker({
				map: map,
				position: results[0].geometry.location,
				icon: image
			});
			marker.setMap(map);	
		} 
		else {
			alert("Geocode was not successful for the following reason: " + status);
		}	
	});
}

function initialize() {
	directionsDisplay = new google.maps.DirectionsRenderer();	
	var mapOptions = {
      zoom: 12,
      center: new google.maps.LatLng(23.0,90.0)
    }
	map = new google.maps.Map(document.getElementById('map_canvas'), mapOptions);
	directionsService =	new google.maps.DirectionsService();
	
	geocodeGivenAddress();
}

function calcRoute() {
  var start = "RAMNA"; //document.getElementById('fromAddress').value;
  var end = document.getElementById('toAddress').value;
  var request = {
    origin: start,
    destination: end,
    travelMode: google.maps.TravelMode.DRIVING
  };
  directionsService.route(request, function(response, status) {
    if (status == google.maps.DirectionsStatus.OK) {
      directionsDisplay.setDirections(response);
    }
  });
}

google.maps.event.addDomListener(window, 'load', initialize);
	//jQuery(initialize);

//})();
</script>

<fieldset>
<legend>চেম্বারে যাওয়ার ম্যাপ</legend>
</fieldset>

<div id="control">
	<form action="#" onsubmit="calcRoute(); return false;">
		<label>আপনার ঠিকানা:</label>
		<input type="text" class="get_input" size="40" id="fromAddress" name="from" value="Ramna"/>
		<input type="hidden" id="toAddress" name="to" value="BUET" />
		<INPUT type="submit" value="ম্যাপ আপডেট করুন..." /></td>
	</form>
</div>


<br/>

	<div id="map_canvas" style="width: 630px; height: 600px"></div>
	<div id="directions" style=""></div>

</div>